
package com.yanboo.generator.rest;

import com.yanboo.common.annotation.CustomController;
import com.yanboo.common.utils.PageResult;

import com.yanboo.generator.service.DriverLocalStorageService;
import com.yanboo.generator.service.dto.DriverLocalStorageDto;
import com.yanboo.generator.service.dto.DriverLocalStorageQueryCriteria;


import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;



@CustomController
@RequiredArgsConstructor
@Tag(name = "")
@RequestMapping("/api/DriverlocalStorage")
public class DriverLocalStorageController {

    private final DriverLocalStorageService localStorageService;

    @GetMapping
    @Operation(summary = "查询文件")
    public ResponseEntity<PageResult<DriverLocalStorageDto>> queryFile(DriverLocalStorageQueryCriteria criteria, Pageable pageable){
        return new ResponseEntity<>(localStorageService.queryAll(criteria,pageable),HttpStatus.OK);
    }

    @PostMapping
    @Operation(summary = "上传文件")
    public ResponseEntity<Object> createFile(@RequestParam String name, @RequestParam("file") MultipartFile file){
        localStorageService.create(name, file);
        return new ResponseEntity<>(HttpStatus.CREATED);
    }
}